package com.xqyq.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.xqyq.dao.UserDao;
import com.xqyq.model.User;

@Service
public class UserService {
	@Autowired
	public UserDao userDao;

	public User register(User user) {
		user.setDetailaddress(user.getProvince() + "省" + user.getCity() + "市"
				+ user.getCounty()  + "区" + user.getDetailaddress());
		int user_id = userDao.register(user);
		if (user_id != 0) {
			return userDao.getUser(user_id);
		} else {
			return null;
		}
	}

	public User login(User user) {
		return userDao.login(user);
	}

	public User get(int user_id) {
		return userDao.getUser(user_id);
	}

	public void update(User user) {
		userDao.update(user);
	}

	public User findUserByEmail(String email) {
		return userDao.getUserByEmail(email);
	}
}
